package com.neusoft.controller;

import com.neusoft.entity.Prescription;
import com.neusoft.service.PrescriptionService;
import com.neusoft.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author akemihomurasama
 */
@RestController
@RequestMapping("/prescription")
@CrossOrigin
public class PrescriptionController {
    @Autowired
    private PrescriptionService prescriptionService;

    /**
     * 向处方表中插入数据列表
     *
     * @param prescriptionList 要插入的数据列表
     * @return 插入结果
     */
    @RequestMapping("/addPrescriptionList")
    public Result addPrescriptionList(@RequestBody List<Prescription> prescriptionList) {
        return prescriptionService.addPrescriptionList(prescriptionList);
    }

    /**
     * 根据条件查询处方列表
     *
     * @param prescription 查询条件
     * @return 处方列表
     */
    @RequestMapping("/queryPrescriptionByCondition")
    public Result queryPrescriptionByCondition(@RequestBody Prescription prescription) {
        return prescriptionService.queryPrescriptionByCondition(prescription);
    }

    /**
     * 根据处方id批量修改处方状态
     *
     * @param drugIdList 药品id列表
     * @param registerId 患者id
     * @return 返回修改结果
     */
    @RequestMapping("/patientDrugPay/{registerId}")
    public Result patientDrugPay(@RequestBody List<Integer> drugIdList, @PathVariable("registerId") int registerId) {
        return prescriptionService.patientDrugPay(drugIdList, registerId);
    }

    /**
     * 给患者发药，修改处方状态为已发药
     *
     * @param drugIdList 药品id列表
     * @param registerId 患者id
     * @return 返回修改结果
     */
    @RequestMapping("/giveDrug/{registerId}")
    public Result giveDrug(@RequestBody List<Integer> drugIdList, @PathVariable("registerId") int registerId) {
        return prescriptionService.giveDrug(drugIdList, registerId);
    }

    /**
     * 给患者退药，修改处方状态为已退药
     *
     * @param drugIdList 药品id列表
     * @param registerId 患者id
     * @return 返回修改结果
     */
    @RequestMapping("/giveUpDrug/{registerId}")
    public Result giveUpDrug(@RequestBody List<Integer> drugIdList, @PathVariable("registerId") int registerId) {
        return prescriptionService.giveUpDrug(drugIdList, registerId);
    }

    /**
     * 处方列表退钱，修改床房状态为已退款
     *
     * @param prescriptionIdList 处方id列表
     * @return 修改结果
     */
    @RequestMapping("/drugMoneyGive")
    public Result drugMoneyGive(@RequestBody List<Integer> prescriptionIdList) {
        return prescriptionService.drugMoneyGive(prescriptionIdList);
    }
}
